/**
 * 
 */
package org.agiba.xwiki.rpc.client;

import java.net.MalformedURLException;
import java.util.List;
import org.apache.xmlrpc.XmlRpcException;
import org.xwiki.xmlrpc.XWikiXmlRpcClient;
import org.xwiki.xmlrpc.model.XWikiPageSummary;

public class PagesInSpace {

   public static void main(String[] args) throws MalformedURLException {

       //URL of the xwiki instance
       String url = "http://localhost:8080/xwiki/xmlrpc/confluence";

       //Replace user & pass with desired xwiki username & password
       String user = "Admin";
        String pass = "admin";

       //Perform Login & Authentication using above url address
       try {
            XWikiXmlRpcClient rpc = new XWikiXmlRpcClient(url);
            rpc.login(user, pass);

           //Pass the "space" name to the getPages method below
           List<XWikiPageSummary> result = rpc.getPages("Main");

           //Print name of the Page, Title & absolute URL for the Pages
           for (XWikiPageSummary rs : result) {

                System.out.println("---" + rs.getId() + "---");
                System.out.println("---" + rs.getTitle() + "---");
                System.out.println("---"+rs.getUrl()+"---");

           }

       } catch (XmlRpcException e) {
            System.out.println("invalid username/password was specified or communication problem.");
            System.out.println(e.getCause());
       }
   }
}
